package com.yxw.yx_hotel.controller;

import com.yxw.yx_hotel.dto.*;
import com.yxw.yx_hotel.service.StayInService;
import com.yxw.yx_hotel.vo.StayInVo;
import com.yxw.yx_hotel.vo.StayRecordVo;
import com.yxw.yx_hotel.vo.StayRetreatVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 *  在住名单管理
 * @author liuxin
 * @date 2024.01.22
 */
@RestController
@Api(value = "在住名单管理", tags = "在住名单管理")
@Slf4j
@RequestMapping("/api/stayIn")
public class StayInController {

    @Autowired
    private StayInService stayInService;


    @ApiOperation(value = "查询在住名单列表")
    @PostMapping("/pageStayInList")
    public BaseResult<PageVO<StayInVo>> pageStayWaitList(@RequestBody QueryInWaitDto dto)  {
        PageVO<StayInVo> pageVo=stayInService.pageStayInList(dto);
        return BaseResult.doSuccess(pageVo,"查询成功");
    }

    @ApiOperation(value = "查询在住详情")
    @GetMapping("/getStayInById")
    public BaseResult<StayInVo> getStayInById(@RequestParam Long stayInId)  {
        StayInVo vo=stayInService.getStayInById(stayInId);
        return BaseResult.doSuccess(vo,"查询成功");
    }


    @ApiOperation(value = "押金缴纳")
    @PostMapping("/payStayInMoney")
    public BaseResult payStayInMoney(@Valid  @RequestBody PayStayInMoneyDto dto)  {
        stayInService.payStayInMoney(dto);
        return BaseResult.doSuccess(null,"缴纳成功");
    }

    @ApiOperation(value = "退住")
    @PostMapping("/stayRetreatByIds")
    public BaseResult stayRetreatByIds(@Valid @RequestBody StayRetreatDto dto)  {
        stayInService.stayRetreatByIds(dto);
        return BaseResult.doSuccess(null,"退住成功");
    }

    @ApiOperation(value = "查询退住名单列表")
    @PostMapping("/pageStayRetreatList")
    public BaseResult<PageVO<StayRetreatVo>> pageStayRetreatList(@RequestBody QueryStayRetreatDto dto)  {
        PageVO<StayRetreatVo> pageVO=stayInService.pageStayRetreatList(dto);
        return BaseResult.doSuccess(pageVO,"查询成功");
    }

    @ApiOperation(value = "查询退住名单详情")
    @PostMapping("/getStayRetreatById")
    public BaseResult<StayRetreatVo> getStayRetreatById(@RequestParam Long retreatId)  {
        StayRetreatVo vo=stayInService.getStayRetreatById(retreatId);
        return BaseResult.doSuccess(vo,"查询成功");
    }
}
